package com.SNQ.project.English_speaking_learning_system.mapper;

import com.SNQ.project.English_speaking_learning_system.aspect.AutoFill;
import com.SNQ.project.English_speaking_learning_system.common.enumeration.OperationType;
import com.SNQ.project.English_speaking_learning_system.pojo.dto.AdminPageQueryDTO;
import com.SNQ.project.English_speaking_learning_system.pojo.entity.Admin;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface AdminMapper {

    /**
     * 根据用户名查询管理员
     * @param username
     * @return
     */
    @Select("select * from admin where username = #{username}")
    Admin getByUsername(String username);

    /**
     * 插入员工数据
     * @param admin
     */
    @Insert("insert into admin (name, username, password, phone, sex, id_number, create_time, update_time, create_user, update_user,status) " +
            "values " +
            "(#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{createTime},#{updateTime},#{createUser},#{updateUser},#{status})")
    @AutoFill(value = OperationType.INSERT)
    void insert(Admin admin);

    /**
     * 分页查询
     * @param adminPageQueryDTO
     * @return
     */
    Page<Admin> pageQuery(AdminPageQueryDTO adminPageQueryDTO);

    /**
     * 根据主键动态修改属性
     * @param admin
     */
    @AutoFill(value = OperationType.UPDATE)
    void update(Admin admin);

    /**
     * 根据id查询管理员信息
     * @param id
     * @return
     */
    @Select("select * from admin where id = #{id}")
    Admin getById(Long id);
}
